/// @tags: FWT
#include <cstdio>
#include <cstring>
#include <iostream>
#define rint register int

using std::cin;
using std::cout;

namespace BlueQuantum {

typedef long long LL;

constexpr int maxn = 1 << 17, mod = 998244353, inv = 499122177;

int A[maxn], B[maxn];

struct FWT {
  int n;
  int f[maxn];

  inline FWT(int n) : n(n) {}

  void OR(bool typ);
  void AND(bool typ);
  void XOR(bool typ);

  inline int &operator[](int index) { return f[index]; }
  inline const int &operator[](int index) const { return f[index]; }
  inline FWT operator*(const FWT &rhs) const {
    FWT res(n);
    for (int i = 0; i < n; ++i) res[i] = 1ll * f[i] * rhs[i] % mod;
    return res;
  }
};

inline void FWT::OR(bool typ) {
  for (int i = 2; i <= n; i <<= 1) {
    int mid = i >> 1;
    for (int j = 0; j < n; j += i)
      for (int k = 0; k < mid; ++k) {
        f[j + k + mid] += typ ? f[j + k] : -f[j + k];
        if (f[j + k + mid] < 0) f[j + k + mid] += mod;
        if (f[j + k + mid] >= mod) f[j + k + mid] -= mod;
      }
  }
}

inline void FWT::AND(bool typ) {
  for (int i = 2; i <= n; i <<= 1) {
    int mid = i >> 1;
    for (int j = 0; j < n; j += i)
      for (int k = 0; k < mid; ++k) {
        f[j + k] += typ ? f[j + k + mid] : -f[j + k + mid];
        if (f[j + k] < 0) f[j + k] += mod;
        if (f[j + k] >= mod) f[j + k] -= mod;
      }
  }
}

inline void FWT::XOR(bool typ) {
  for (int i = 2; i <= n; i <<= 1) {
    int mid = i >> 1;
    for (int j = 0; j < n; j += i)
      for (int k = 0; k < mid; ++k) {
        int tmp = f[j + k + mid];
        if ((f[j + k + mid] = f[j + k] - tmp) < 0) f[j + k + mid] += mod;
        if ((f[j + k] += tmp) >= mod) f[j + k] -= mod;
        if (!typ) {
          f[j + k] = (LL)inv * f[j + k] % mod;
          f[j + k + mid] = (LL)inv * f[j + k + mid] % mod;
        }
      }
  }
}

inline std::ostream &operator<<(std::ostream &os, const FWT &rhs) {
  for (int i = 0; i < rhs.n; ++i) os << rhs[i] << ' ';
  return os;
}

inline int main() {
  int n;
  cin >> n;
  int maxl = 1 << n;
  for (int i = 0; i < maxl; ++i) cin >> A[i];
  for (int i = 0; i < maxl; ++i) cin >> B[i];
  FWT a(maxl), b(maxl);
  memcpy(a.f, A, sizeof(A)), memcpy(b.f, B, sizeof(B));
  a.OR(true), b.OR(true);
  FWT c(a * b);
  c.OR(false);
  cout << c << '\n';
  memcpy(a.f, A, sizeof(A)), memcpy(b.f, B, sizeof(B));
  a.AND(true), b.AND(true);
  c = a * b;
  c.AND(false);
  cout << c << '\n';
  memcpy(a.f, A, sizeof(A)), memcpy(b.f, B, sizeof(B));
  a.XOR(true), b.XOR(true);
  c = a * b;
  c.XOR(false);
  cout << c << '\n';
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("FWT.in", "r", stdin);
  freopen("FWT.out", "w", stdout);
#endif
#endif

  std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
